package com.ruoyi.controller;

import com.ruoyi.dto.ResponseDTO;
import com.ruoyi.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin
@RestController
public class GoodController {
    @Autowired
    private GoodService goodService;
    @RequestMapping("/index")
    public String index() {
        return "index";
    }
    @RequestMapping("/getAllType")
    public ResponseDTO getAllType() {

        return goodService.getAllType();
    }

    @RequestMapping("/getGoodsByType")
    public ResponseDTO getGoodsByType(@RequestParam String id,@RequestParam String storeId) {

        return goodService.getGoodsByType(id,storeId);
    }
    @RequestMapping("/addGood")
    public ResponseDTO addGood(@RequestParam String storeId,@RequestParam String name, @RequestParam String price,@RequestParam String remark,@RequestParam String typeId,@RequestParam String image) {

        return goodService.addGood(storeId,name,price,remark,typeId,image);
    }
    @RequestMapping("/editGood")
    public ResponseDTO editGood(@RequestParam String storeId,@RequestParam String id,@RequestParam String name, @RequestParam String price,@RequestParam String remark,@RequestParam String typeId,@RequestParam String image) {
        System.out.println(price);
        return goodService.editGood(storeId,id,name,price,remark,typeId,image);
    }
    @RequestMapping("/deleteGood")
    public ResponseDTO deleteGood(@RequestParam String storeId,@RequestParam String id) {

        return goodService.deleteGood(storeId,id);
    }
    @RequestMapping("/addClass")
    public ResponseDTO addClass(@RequestParam String name,@RequestParam String image) {

        return goodService.addClass(name,image);
    }
    @RequestMapping("/editClass")
    public ResponseDTO editClass(@RequestParam String id,@RequestParam String name,@RequestParam String image) {

        return goodService.editClass(id,name,image);
    }
    @RequestMapping("/deleteClass")
    public ResponseDTO deleteClass(@RequestParam String id) {

        return goodService.deleteClass(id);
    }
    @RequestMapping("/searchGood")
    public ResponseDTO searchGood(@RequestParam String storeId,@RequestParam String name) {

        return goodService.searchGood(storeId,name);
    }
}
